#!/usr/bin/env python
# -*- coding: gbk -*-
# @Time : 2022/4/5 22:11
# @Author : Aries
# @Site : 
# @File : pymysql_weibo.py
# @Software: PyCharm

import pymysql

conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', password='geliang', db='spider_project',
                       charset='utf8')
cur = conn.cursor()


def insert_into_data(namess, id, location, description, text, levels):
    try:
        sql = 'insert into tb_weibo_content(namess,id,location,description,text,levels) values (%s,%s,%s,%s,%s,%s)'
        cur.execute(sql, (namess, id, location, description, text, levels))
        conn.commit()
    except Exception as e:
        print(e)
        conn.rollback()
